Load all required libraries.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.3 v dplyr 1.0.7
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 2.0.0 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(broom)
Read in raw data from RDS.
raw_data <- readRDS("./year2.RDS")
Make a few small modifications to names and data for visualizations.
final_data <- raw_data %>% mutate(log_copy_per_L = log10(mean_copy_num_L)) %>%
rename(Facility = wrf) %>%
mutate(Facility = recode(Facility,
"NO" = "WRF A",
"MI" = "WRF B",
"CC" = "WRF C"))
Seperate the data by gene target to ease layering in the final plot
#make three data layers
only_positives <<- subset(final_data, (!is.na(final_data$Facility)))
only_n1 <- subset(only_positives, target == "N1")
only_n2 <- subset(only_positives, target == "N2")
only_background <<-final_data %>%
select(c(date, cases_cum_clarke, new_cases_clarke, X7_day_ave_clarke)) %>%
group_by(date) %>% summarise_if(is.numeric, mean)
#specify fun colors
background_color <- "#7570B3"
seven_day_ave_color <- "#E6AB02"
marker_colors <- c("N1" = '#1B9E77',"N2" ='#D95F02')
#remove facilty C for now
#only_n1 <- only_n1[!(only_n1$Facility == "WRF C"),]
#only_n2 <- only_n2[!(only_n2$Facility == "WRF C"),]
only_n1 <- only_n1[!(only_n1$Facility == "WRF A" & only_n1$date == "2020-11-02"), ]
only_n2 <- only_n2[!(only_n2$Facility == "WRF A" & only_n2$date == "2020-11-02"), ]
Build the main plot
#first layer is the background epidemic curve
p1 <- only_background %>%
plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~new_cases_clarke,
type = "bar",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Daily Cases: ', new_cases_clarke),
alpha = 0.5,
name = "Daily Reported Cases",
color = background_color,
colors = background_color,
showlegend = FALSE) %>%
layout(yaxis = list(title = "Clarke County Daily Cases", showline=TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#renders the main plot layer two as seven day moving average
p1 <- p1 %>% plotly::add_trace(x = ~date, y = ~X7_day_ave_clarke,
type = "scatter",
mode = "lines",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Seven-Day Moving Average: ', X7_day_ave_clarke),
name = "Seven Day Moving Average Athens",
line = list(color = seven_day_ave_color),
showlegend = FALSE)
#renders the main plot layer three as positive target hits
p2 <- plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n1,
symbol = ~Facility,
marker = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n2,
symbol = ~Facility,
marker = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(yaxis = list(title = "SARS CoV-2 Copies/L",
showline = TRUE,
type = "log",
dtick = 1,
automargin = TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#adds the limit of detection dashed line
p2 <- p2 %>% plotly::add_segments(x = as.Date("2021-06-30"),
xend = ~max(date + 10),
y = 3571.429, yend = 3571.429,
opacity = 0.35,
line = list(color = "black", dash = "dash")) %>%
layout(annotations = list(x = as.Date("2021-06-30"), y = 3.8, xref = "x", yref = "y",
text = "Limit of Detection", showarrow = FALSE))
p1
p2
Combine the two main plot pieces as a subplot
#seperate n1 and n2 frames by site
#n1
wrf_a_only_n1 <- subset(only_n1, Facility == "WRF A")
wrf_b_only_n1 <- subset(only_n1, Facility == "WRF B")
wrf_c_only_n1 <- subset(only_n1, Facility == "WRF C")
#n2
wrf_a_only_n2 <- subset(only_n2, Facility == "WRF A")
wrf_b_only_n2 <- subset(only_n2, Facility == "WRF B")
wrf_c_only_n2 <- subset(only_n2, Facility == "WRF C")
#rejoin the old data frames then seperate in to averages for each plant.
wrfa_both <- full_join(wrf_a_only_n1, wrf_a_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfb_both <- full_join(wrf_b_only_n1, wrf_b_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfc_both <- full_join(wrf_c_only_n1, wrf_c_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
#get max date
maxdate <- max(wrfa_both$date)
mindate <- min(wrfa_both$date)
Build loess smoothing figures figures
This makes the individual plots
#**************************************WRF A PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_botha <- ggplot(wrfa_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_botha<<-..y..), method = "loess", color = '#1B9E77',
span = 0.3, n = 239)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_botha
## `geom_smooth()` using formula 'y ~ x'
fit_botha
## [1] 11.53706 11.57476 11.61216 11.64927 11.68608 11.72260 11.75882 11.79475
## [9] 11.83040 11.86575 11.90081 11.93559 11.97009 12.00426 12.03811 12.07164
## [17] 12.10488 12.13785 12.17059 12.20310 12.23545 12.26762 12.29959 12.33130
## [25] 12.36271 12.39378 12.42446 12.45469 12.48443 12.51374 12.54267 12.57127
## [33] 12.59961 12.62771 12.65621 12.68537 12.71477 12.74394 12.77245 12.79985
## [41] 12.82570 12.85250 12.88209 12.91298 12.94369 12.97275 12.99868 13.02000
## [49] 13.03983 13.06142 13.08348 13.10474 13.12394 13.13979 13.15103 13.16021
## [57] 13.17008 13.17962 13.18783 13.19368 13.19616 13.19427 13.18741 13.17620
## [65] 13.16145 13.14397 13.12458 13.10407 13.08327 13.06299 13.03776 13.00401
## [73] 12.96535 12.92541 12.88780 12.85615 12.82545 12.78963 12.75064 12.71049
## [81] 12.67113 12.63455 12.60273 12.57052 12.53308 12.49284 12.45225 12.41372
## [89] 12.37971 12.35264 12.33053 12.30973 12.29018 12.27182 12.25457 12.23838
## [97] 12.22319 12.21101 12.20306 12.19803 12.19466 12.19164 12.18770 12.18154
## [105] 12.17570 12.17295 12.17231 12.17283 12.17353 12.17345 12.17163 12.16832
## [113] 12.16466 12.16102 12.15776 12.15527 12.15392 12.15406 12.15511 12.15632
## [121] 12.15780 12.15967 12.16207 12.16511 12.16891 12.17387 12.18002 12.18697
## [129] 12.19433 12.20172 12.20873 12.21497 12.22338 12.23598 12.25109 12.26698
## [137] 12.28197 12.29434 12.30239 12.30965 12.31984 12.33160 12.34353 12.35428
## [145] 12.36245 12.36667 12.36422 12.35470 12.34023 12.32290 12.30483 12.28812
## [153] 12.27489 12.26723 12.26726 12.26824 12.26382 12.25676 12.24979 12.24567
## [161] 12.24713 12.25691 12.27303 12.29138 12.31156 12.33313 12.35568 12.37879
## [169] 12.40203 12.43122 12.47105 12.51941 12.57420 12.63330 12.69462 12.75605
## [177] 12.81548 12.87081 12.91992 12.96072 12.99110 13.02043 13.05759 13.09968
## [185] 13.14384 13.18719 13.22685 13.25994 13.28360 13.29494 13.29465 13.28660
## [193] 13.27264 13.25463 13.23444 13.21394 13.19498 13.17074 13.13544 13.09247
## [201] 13.04525 12.99717 12.95165 12.91208 12.87281 12.82742 12.77819 12.72739
## [209] 12.67730 12.63018 12.58832 12.54853 12.50665 12.46350 12.41990 12.37666
## [217] 12.33459 12.29451 12.25526 12.21535 12.17508 12.13475 12.09468 12.05517
## [225] 12.01653 11.97838 11.94018 11.90204 11.86405 11.82632 11.78892 11.75196
## [233] 11.71560 11.67985 11.64462 11.60980 11.57529 11.54099 11.50680
#assign fits to a vector
both_trenda <- fit_botha
#extract y min and max for each
limits_botha <- ggplot_build(extract_botha)$data
## `geom_smooth()` using formula 'y ~ x'
limits_botha <- as.data.frame(limits_botha)
both_ymina <- limits_botha$ymin
both_ymaxa <- limits_botha$ymax
#reassign dataframes (just to be safe)
work_botha <- wrfa_both
#fill in missing dates to smooth fits
work_botha <- work_botha %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_botha <- work_botha$date
#create a new smooth dataframe to layer
smooth_frame_botha <- data.frame(date_vec_botha, both_trenda, both_ymina, both_ymaxa)
#WRF A
#plot smooth frames
p_wrf_a <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_botha, y = ~both_trenda,
data = smooth_frame_botha,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha,
'</br> Median Log Copies: ', round(both_trenda, digits = 2)),
line = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_botha, ymin = ~both_ymina, ymax = ~both_ymaxa,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxa, digits = 2),
'</br> Min Log Copies: ', round(both_ymina, digits = 2)),
name = "",
fillcolor = '#1B9E77',
line = list(color = '#1B9E77')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF A") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfa_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#1B9E77', size = 6, opacity = 0.65))
p_wrf_a
save(p_wrf_a, file = "./site_objects/wrf_a_year2.rda")
#**************************************WRF B PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothb <- ggplot(wrfb_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothb<<-..y..), method = "loess", color = '#D95F02',
span = 0.3, n = 239)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothb
## `geom_smooth()` using formula 'y ~ x'
fit_bothb
## [1] 10.69891 10.79386 10.88682 10.97778 11.06674 11.15368 11.23860 11.32148
## [9] 11.40233 11.48114 11.55788 11.63256 11.70518 11.77568 11.84408 11.91039
## [17] 11.97466 12.03692 12.09720 12.15553 12.21155 12.26503 12.31618 12.36524
## [25] 12.41241 12.45793 12.50200 12.54411 12.58374 12.62113 12.65654 12.69019
## [33] 12.72234 12.75324 12.78214 12.80840 12.83239 12.85449 12.87508 12.89455
## [41] 12.91327 12.92876 12.93919 12.94598 12.95055 12.95430 12.95865 12.96501
## [49] 12.97175 12.97657 12.97984 12.98197 12.98334 12.98435 12.98539 12.98541
## [57] 12.98352 12.98032 12.97639 12.97233 12.96873 12.96618 12.96351 12.95938
## [65] 12.95414 12.94814 12.94174 12.93530 12.92916 12.92369 12.91927 12.91563
## [73] 12.91207 12.90791 12.90248 12.89508 12.88773 12.88222 12.87754 12.87265
## [81] 12.86654 12.85819 12.84658 12.83213 12.81620 12.79912 12.78123 12.76288
## [89] 12.74441 12.72615 12.70637 12.68376 12.65927 12.63388 12.60855 12.58427
## [97] 12.56200 12.54155 12.52170 12.50181 12.48127 12.45945 12.43572 12.40946
## [105] 12.38028 12.34875 12.31565 12.28179 12.24799 12.21503 12.18373 12.14680
## [113] 12.09959 12.04680 11.99317 11.94340 11.90221 11.87432 11.85025 11.81978
## [121] 11.78652 11.75408 11.72610 11.70618 11.69794 11.69925 11.70497 11.71415
## [129] 11.72589 11.73925 11.75330 11.76712 11.78770 11.81992 11.85971 11.90296
## [137] 11.94561 11.98356 12.01272 12.04532 12.09256 12.14885 12.20858 12.26615
## [145] 12.31597 12.35242 12.37992 12.40663 12.43257 12.45776 12.48224 12.50602
## [153] 12.52912 12.55158 12.57341 12.58893 12.59491 12.59512 12.59329 12.59318
## [161] 12.59854 12.61312 12.63169 12.64729 12.66109 12.67426 12.68797 12.70339
## [169] 12.72168 12.74587 12.77723 12.81431 12.85567 12.89986 12.94542 12.99091
## [177] 13.03488 13.07588 13.11246 13.14317 13.16656 13.18645 13.20715 13.22801
## [185] 13.24838 13.26758 13.28497 13.29987 13.31163 13.31958 13.32416 13.32633
## [193] 13.32628 13.32420 13.32025 13.31462 13.30748 13.29784 13.28496 13.26940
## [201] 13.25172 13.23250 13.21231 13.19171 13.17023 13.14711 13.12241 13.09621
## [209] 13.06858 13.03961 13.00937 12.97781 12.94485 12.91047 12.87466 12.83741
## [217] 12.79869 12.75851 12.71691 12.67396 12.62960 12.58380 12.53654 12.48776
## [225] 12.43744 12.38561 12.33233 12.27760 12.22141 12.16375 12.10461 12.04400
## [233] 11.98189 11.91830 11.85324 11.78670 11.71870 11.64924 11.57833
#assign fits to a vector
both_trendb <- fit_bothb
#extract y min and max for each
limits_bothb <- ggplot_build(extract_bothb)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothb <- as.data.frame(limits_bothb)
both_yminb <- limits_bothb$ymin
both_ymaxb <- limits_bothb$ymax
#reassign dataframes (just to be safe)
work_bothb <- wrfb_both
#fill in missing dates to smooth fits
work_bothb <- work_bothb %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothb <- work_bothb$date
#create a new smooth dataframe to layer
smooth_frame_bothb <- data.frame(date_vec_bothb, both_trendb, both_yminb, both_ymaxb)
#WRF B
#plot smooth frames
p_wrf_b <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothb, y = ~both_trendb,
data = smooth_frame_bothb,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb,
'</br> Median Log Copies: ', round(both_trendb, digits = 2)),
line = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothb, ymin = ~both_yminb, ymax = ~both_ymaxb,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxb, digits = 2),
'</br> Min Log Copies: ', round(both_yminb, digits = 2)),
name = "",
fillcolor = '#D95F02',
line = list(color = '#D95F02')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF B") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfb_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#D95F02', size = 6, opacity = 0.65))
p_wrf_b
save(p_wrf_b, file = "./site_objects/wrf_b_year2.rda")
#**************************************WRF C PLOT********************************************** #add trendlines #extract data from geom_smooth # *********************************span 0.6*********************************** #*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothc <- ggplot(wrfc_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothc<<-..y..), method = "loess", color = '#E7298A',
span = 0.3, n = 239)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothc
## `geom_smooth()` using formula 'y ~ x'
fit_bothc
## [1] 10.79612 10.86539 10.93323 10.99960 11.06449 11.12785 11.18967 11.24992
## [9] 11.30855 11.36556 11.42090 11.47455 11.52649 11.57666 11.62512 11.67196
## [17] 11.71728 11.76119 11.80378 11.84515 11.88450 11.92127 11.95594 11.98898
## [25] 12.02086 12.05207 12.08307 12.11142 12.13527 12.15596 12.17488 12.19338
## [33] 12.21283 12.23458 12.25737 12.27914 12.30010 12.32046 12.34042 12.36020
## [41] 12.38000 12.40103 12.42375 12.44731 12.47084 12.49347 12.51434 12.53257
## [49] 12.55011 12.56887 12.58792 12.60631 12.62311 12.63740 12.64822 12.65669
## [57] 12.66439 12.67110 12.67660 12.68067 12.68311 12.68368 12.68223 12.67891
## [65] 12.67401 12.66782 12.66062 12.65272 12.64438 12.63590 12.62399 12.60667
## [73] 12.58617 12.56472 12.54456 12.52790 12.51322 12.49755 12.48100 12.46368
## [81] 12.44572 12.42721 12.40829 12.38713 12.36272 12.33629 12.30912 12.28246
## [89] 12.25756 12.23568 12.21338 12.18753 12.15988 12.13215 12.10608 12.08343
## [97] 12.06592 12.05169 12.03784 12.02456 12.01204 12.00049 11.99007 11.98100
## [105] 11.97427 11.97018 11.96788 11.96651 11.96521 11.96314 11.95942 11.95725
## [113] 11.95928 11.96388 11.96938 11.97416 11.97656 11.97494 11.97174 11.97010
## [121] 11.96945 11.96919 11.96875 11.96754 11.96498 11.96030 11.95367 11.94593
## [129] 11.93789 11.93039 11.92426 11.92031 11.91730 11.91352 11.90909 11.90412
## [137] 11.89873 11.89304 11.88716 11.88011 11.87138 11.86176 11.85206 11.84309
## [145] 11.83565 11.83055 11.82473 11.81548 11.80417 11.79214 11.78075 11.77136
## [153] 11.76532 11.76399 11.76871 11.77645 11.78379 11.79153 11.80046 11.81138
## [161] 11.82508 11.84238 11.86260 11.88444 11.90771 11.93222 11.95778 11.98421
## [169] 12.01131 12.04373 12.08512 12.13377 12.18797 12.24600 12.30615 12.36673
## [177] 12.42601 12.48229 12.53386 12.57901 12.61602 12.65172 12.69273 12.73705
## [185] 12.78270 12.82768 12.87000 12.90767 12.93869 12.96107 12.97769 12.99251
## [193] 13.00522 13.01549 13.02298 13.02738 13.02836 13.02488 13.01676 13.00492
## [201] 12.99028 12.97377 12.95633 12.93888 12.91942 12.89599 12.86950 12.84088
## [209] 12.81108 12.78101 12.75160 12.72223 12.69153 12.65933 12.62546 12.58975
## [217] 12.55203 12.51213 12.47018 12.42646 12.38094 12.33364 12.28455 12.23369
## [225] 12.18104 12.12655 12.07017 12.01196 11.95198 11.89027 11.82688 11.76188
## [233] 11.69527 11.62702 11.55710 11.48549 11.41216 11.33709 11.26026
#assign fits to a vector
both_trendc <- fit_bothc
#extract y min and max for each
limits_bothc <- ggplot_build(extract_bothc)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothc <- as.data.frame(limits_bothc)
both_yminc <- limits_bothc$ymin
both_ymaxc <- limits_bothc$ymax
#reassign dataframes (just to be safe)
work_bothc <- wrfc_both
#fill in missing dates to smooth fits
work_bothc <- work_bothc %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothc <- work_bothc$date
#create a new smooth dataframe to layer
smooth_frame_bothc <- data.frame(date_vec_bothc, both_trendc, both_yminc, both_ymaxc)
#WRF C
#plot smooth frames
p_wrf_c <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothc, y = ~both_trendc,
data = smooth_frame_bothc,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc,
'</br> Median Log Copies: ', round(both_trendc, digits = 2)),
line = list(color = '#E7298A', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothc, ymin = ~both_yminc, ymax = ~both_ymaxc,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxc, digits = 2),
'</br> Min Log Copies: ', round(both_yminc, digits = 2)),
name = "",
fillcolor = '#E7298A',
line = list(color = '#E7298A')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF C") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfc_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#E7298A', size = 6, opacity = 0.65))
p_wrf_c
save(p_wrf_c, file = "./site_objects/wrf_c_year2.rda")
keeping in case
#save(wrfa_both, file = "./plotly_objs/wrfa_both.rda")
#save(wrfb_both, file = "./plotly_objs/wrfb_both.rda")
#save(wrfc_both, file = "./plotly_objs/wrfc_both.rda")
#save(date_vec_botha, file = "./plotly_objs/date_vec_botha.rda")
#save(date_vec_bothb, file = "./plotly_objs/date_vec_bothb.rda")
#save(date_vec_bothc, file = "./plotly_objs/date_vec_bothc.rda")
#save(both_ymina, file = "./plotly_objs/both_ymina.rda")
#save(both_ymaxa, file = "./plotly_objs/both_ymaxa.rda")
#save(both_yminb, file = "./plotly_objs/both_yminb.rda")
#save(both_ymaxb, file = "./plotly_objs/both_ymaxb.rda")
#save(both_yminc, file = "./plotly_objs/both_yminc.rda")
#save(both_ymaxc, file = "./plotly_objs/both_ymaxc.rda")